package order

import (
	"zpay/pkg/app"
	"zpay/pkg/database"
	"zpay/pkg/paginator"

	"github.com/gin-gonic/gin"
)

// GetByOrderNo 通过订单号查询
func GetByOrderNo(order_no string) (orderModel Order) {
	database.DB.Where("order_no = ?", order_no).First(&orderModel)
	return
}

// Paginate 分页内容
func Paginate(c *gin.Context, perPage int) (orders []Order, paging paginator.Paging) {
	paging = paginator.Paginate(
		c,
		database.DB.Model(Order{}),
		&orders,
		app.V1URL(database.TableName(&Order{})),
		perPage,
	)
	return
}
